home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 5681 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  5.3 KB

  1. Path: news.NetVision.net.il!news
  2. From: Jack <avilev@netvision.net.il>
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Re: 680X0 -> PPC translator?
  5. Date: Fri, 15 Mar 1996 08:49:18 -0800
  6. Organization: NetVision LTD.
  7. Message-ID: <31499F8E.26A9@netvision.net.il>
  8. References: <313D3A8F.148C@sapiens.com> <volker.0fpv@vb.franken.de> <3143E4EB.7303@sapiens.com> <volker.0fsu@vb.franken.de>
  9. NNTP-Posting-Host: ts011p8.pop4a.netvision.net.il
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0b6a (Win16; I)
  14.  
  15. Volker Barthelmann wrote:
  16. > In article <3143E4EB.7303@sapiens.com> you wrote:
  17. > :
  18. > : Well, even so it still doesn't affect the translation process and that's simply becuase in
  19. > : order to make a dynamic call (ie run-time address calc.) the base address of the function is
  20. > : referenced somewhere in the program right?!
  21. > It doesn't have to be.
  22.  
  23. oh is that so?! unless you get the address from an outside source, such as allocating it YOU 
  24. must produce it, right?! so you have to have it stored somewhere in the program. if you get it 
  25. from some outside source, such as malloc(), then you don't have it obviously but that being said 
  26. doesn't imply it's impossible to figure out in which context the address is being used (ie code 
  27. or data) and make the proper modifications to the code. also bear in mind that all system 
  28. functions return pointers in either a0 or a1 and then that pointer is saved somewhere in memory 
  29. for later use, if the usage involves executing code in that part of memory then it's easy to 
  30. trace the call to malloc() or what ever else and change the required size according to the 
  31. calculated code size, remember that the code is sitting somewhere inside your executable and 
  32. therefore its size is known, comparing this value to the values pushed to the stack before the 
  33. malloc() call and you would find the exact word address to change. though it sounds complex, 
  34. nothing in life is really that simple.
  35.  
  36.  
  37. > : so you can collect all these addresses and then see
  38. > : where they're used as jump/call operands in an indirect call somewhere else in the program.
  39. > Easy said, but really doing this is a different story. First, You'll have to
  40. > kind of disassemble the program and therefore You have to know what is data
  41. > and what is code, but that's what You want to decide, so...
  42. > Also doing this kind of analysis is pretty much impossible on Assembler code.
  43. > your mind is too cluttered with the complexity of things, but saying it isn't possible is simply 
  44. an unfounded claim. true things aren't that simple as with dynamic translation, but with a 
  45. little more effort they can be done, quite reliably too. and besides who says that dynamic 
  46. approach won't have the same difficulties as the static one, i can see the problem of 
  47. self-modifying code as not so easy to solve even in dynamic translation. that's because, as you 
  48. said what happens if the destination address was dynamically allocated, then you would have to 
  49. change its size again, wouldn't you?! 
  50.  
  51. > : remember that all such addresses are 'lea'ed somewhere in the program and probably stored in
  52. > : some variable in memory and when needed is used to load an address register for making the jump
  53. > And a variable in memory in assembler looks like xyz(a7), but only at one
  54. > point, because at another point it is xyz+c(a7). It is probably impossible
  55. > to detect if they point to the same address.
  56.  
  57. so what??? if you follow the changes made to a7, assuming an initial value of 0, you would 
  58. always know what address you're refering to right, doesn't matter how you try to disguise it, 
  59. and if you're keeping track of what is being done with that address location you can figure out 
  60. what the hell it is, either code or data. you havn't obviously been listening to what i've said, 
  61. the translator isn't by any measure a stupid one, it must 'understand' the code it's translating 
  62. and make the proper modification to make it work. of course there will be exceptions to its 
  63. capablity cuz some assumptions are taken for granted, such as register usage etc, but for most 
  64. ansi-compliant programs, it will damn right be a very good tool and most compilers i know are 
  65. ansi-compliant.
  66. > : or simply used directly, in either case to resolve the problem of dynamic address resolution,
  67. > : address context analysis must be performed on EACH such address in the program, while it
  68. > : implies hugh data structures, it is very much theoratically possible. also bear in mind that
  69. > It is not theoretically possible. There are some simple cases where it may
  70. > work, that's all.
  71. > : all external references are assumed to be translated code already, so we don't care about that
  72. > : but ALL internal references can be resolved because SOMEWHERE, SOMEONE must have used them and
  73. > : don't tell me that function addresses are being used in arithmatic calculations, that is simply
  74. > : weird programming, don't you agree and so the exact entry point is located somewhere in the
  75. > I don't agree.
  76. > Function addresses are often used in arithmetic calculations. Examples are
  77. > copying of code or control-structures like in special switch-statements.
  78. > are you sure you're talking about functions and not just jump addresses, while similar they're 
  79. NOT the same thing. i'm talking about complete functions and their entry point is fixed and 
  80. therefore can't be calculated.
  81.  
  82. -
  83.  
  84. Avi Lev.
  85.